package oakclub.entity;

import oakclub.global.Context;

import java.util.HashMap;
import java.util.Map;

public class BackgroundEntity extends BaseEntity
{
    private ContextEntity context;
    private Map<String, Object> params = new HashMap<>();

    public BackgroundEntity()
    {
        this.context = Context.get();
    }

    public BackgroundEntity(Object ... pair)
    {
        this();
        this.addParam(pair);
    }

    public BackgroundEntity addParam(String key, Object obj)
    {
        this.params.put(key, obj);
        return this;
    }

    public BackgroundEntity addParam(Object ... pair)
    {
        if(pair.length % 2 != 0)
        {
            throw new IllegalArgumentException("Number of param must be even");
        }

        for(int i = 0; i < pair.length; i+=2)
        {
            this.params.put((String) pair[i], pair[i + 1]);
        }

        return this;
    }

    public ContextEntity getContext()
    {
        return context;
    }

    public Map<String, Object> getParams()
    {
        return params;
    }

    public void setParams(Map<String, Object> params)
    {
        this.params = params;
    }

    public Object getParam(String key)
    {
        return this.params.get(key);
    }
}
